﻿@using OSBLE.Controllers;
@model CookieTestController.CookieModel
@{
    ViewBag.Title = "Index";
    Layout = null;
}
<link rel="stylesheet" type="text/css" href="/Content/jquery-ui-1.8.13.custom.css" />
    <link rel="stylesheet" type="text/css" href="/Content/jquery-ui-timepicker.css" />
    <link rel="shortcut icon" type="text/css" href="/Content/favicon.ico" />

    <script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.collapse.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.easing.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.ui.timepicker.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.tmpl.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.selectboxes.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-tooltip.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Silverlight.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/osble.js")" type="text/javascript"></script>

<h2>Cookie Test</h2>
@using (Html.BeginForm())
{
    <table border="1" padding="3">
        <tr>
            <td>Name:</td>
            <td>@Html.EditorFor(m => m.Name)</td>
        </tr>
    </table>
    <input type="submit" name="submit" value="submit" />
}
<div id="results">

</div>
<script type="text/javascript">
var cookieName = '@(Model.Name)';
if (cookieName != "") {
    window.setInterval("time()", 5 * 60000);
    time();
}

var isTimedOut = false;
function time() {
    $.ajax({
        url: "/CookieTest/CheckCookie",
        success: complete,
        failure: function (result) {
            if (!isTimedOut) {
                alert("The session has timed out.  To avoid losing work on this page, please open a new browser window and re-log into OSBLE.");
                isTimedOut = true;
            }
        }
    });
}

function complete(data) {
    $('#results').append("<p>Name: " + data.Name + ", Session: " + data.SessionValue + " Time: " + data.Time + "</p>");
}

</script>
